package thread.java20221201;

/**
 * 后台线程
 */
public class Demo9 {
    public static void main(String[] args) throws InterruptedException {
        Thread t1 = new Thread(()->{
            for (int i = 0; i < 5; i++) {
                System.out.println(9999);
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        });

        t1.setDaemon(true);//设置t1为后台线程
        t1.start();
        Thread.sleep(2000);
        System.out.println("主线程结束");

    }
}
